package jeulin.mobile.view;

import java.util.ArrayList;

import jeulin.mobile.R;
import jeulin.mobile.BDD.Appart;
import jeulin.mobile.BDD.Bloc;
import android.app.Activity;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

public class BlocResume extends Activity{

	private Context ctxt;
	private ArrayList<Appart> apparts;
	private SQLiteDatabase db;
	
	public BlocResume(Context p_ctxt, SQLiteDatabase p_db, int idAdresse){
		this.ctxt = p_ctxt;
		this.db = p_db;
		//apparts = Appart.getApparts(db, idAdresse);
		this.generateFiche();
	}
	
	public void generateFiche(){
		if(apparts != null){
			LinearLayout lyt = new LinearLayout(ctxt);
			
			for(int i=0 ; i<apparts.size() ; ++i){
				
				lyt.addView(generateLigne(i));
			}
		}
	}
	
	private View generateLigne(int i){
		LayoutInflater inflater = getLayoutInflater();
		View v = (View) inflater.inflate(R.layout.fiche, null);
		
		Appart a = apparts.get(i);
		
		EditText releve = (EditText)v.findViewById(R.id.releve);
		releve.setText(a.getReleve());
		
		EditText pose = (EditText)v.findViewById(R.id.pose);
		pose.setText(a.getPose());
		
		EditText inter = (EditText)v.findViewById(R.id.inter);
		inter.setText(a.getPlaceInter());
		
		EditText bl = (EditText)v.findViewById(R.id.bl);
		bl.setText(a.getPlaceBaL());
		
		EditText num1 = (EditText)v.findViewById(R.id.num1);
		num1.setText(a.getNum1());
		
		EditText num2 = (EditText)v.findViewById(R.id.num2);
		num2.setText(a.getNum2());
		
		EditText num3 = (EditText)v.findViewById(R.id.num3);
		num3.setText(a.getNum3());
		
		EditText num4 = (EditText)v.findViewById(R.id.num4);
		num4.setText(a.getNum4());
		
		EditText num5 = (EditText)v.findViewById(R.id.num5);
		num5.setText(a.getNum5());
		
		EditText num6 = (EditText)v.findViewById(R.id.num6);
		num6.setText(a.getNum6());
		
		EditText num7 = (EditText)v.findViewById(R.id.num7);
		num7.setText(a.getNum7());
		
		EditText num8 = (EditText)v.findViewById(R.id.num8);
		num8.setText(a.getNum8());
		
		EditText num9 = (EditText)v.findViewById(R.id.num9);
		num9.setText(a.getNum9());
		
		EditText num10 = (EditText)v.findViewById(R.id.num10);
		num10.setText(a.getNum10());
		
		EditText num11 = (EditText)v.findViewById(R.id.num11);
		num11.setText(a.getNum11());
		
		EditText num12 = (EditText)v.findViewById(R.id.num12);
		num12.setText(a.getNum12());
		
		EditText nom = (EditText)v.findViewById(R.id.nom);
		nom.setText("");
		
		EditText nbBl = (EditText)v.findViewById(R.id.nbBl);
		nbBl.setText("");
		
		EditText nbInter = (EditText)v.findViewById(R.id.nbInter);
		nbInter.setText("");
		
		EditText nbPorte = (EditText)v.findViewById(R.id.nbPorte);
		nbPorte.setText("");
		
		EditText nbProtectBl = (EditText)v.findViewById(R.id.nbProtectBl);
		nbProtectBl.setText("");
		
		EditText nbSupportInter = (EditText)v.findViewById(R.id.nbSupportInter);
		nbSupportInter.setText("");
		
		EditText nbPub = (EditText)v.findViewById(R.id.nbPub);
		nbPub.setText("");
		
		TextView total = (TextView)v.findViewById(R.id.total);
		total.setText(0);
		
		TextView numLot = (TextView)v.findViewById(R.id.num);
		numLot.setText(a.getNumLot());
		
		return v;
	}

	
}
